package com.dingding.order.core.common.rule.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.dingding.common.core.util.ToolUtil;
import com.dingding.order.common.dto.rule.ReqValuationRule;
import com.dingding.order.common.dto.rule.ReqValuationRuleByVehicleId;
import com.dingding.order.common.dto.rule.ResValuationRule;
import com.dingding.order.core.common.rule.dao.IValuationRuleDao;
import com.dingding.order.core.common.rule.service.IValuationRuleService;

/**
 * 
 * @ClassName: ValuationRuleServiceImpl 
 * @Description: 计价规则业务逻辑接口实现类
 * @author YHQ
 * @date 2016年12月7日 下午2:49:47
 * @since V2.5.7
 * 
 */
@Component("valuationRuleService")
public class ValuationRuleServiceImpl implements IValuationRuleService{

	@Resource(name = "valuationRuleDao")
	private IValuationRuleDao valuationRuleDao;
	
	/**
	 * 
	 * @Title: getChargeRuleList 
	 * @Description: 根据城市Id获取该城市的每个有效车型的计价规则 
	 * @param reqValuationRule 客户端请求参数
	 * @author YHQ 
	 * @since V2.5.7
	 * @return List<ResValuationRule>    返回类型
	 * 
	 */
	@Override
	public List<ResValuationRule> getChargeRuleList(ReqValuationRule reqValuationRule) {
		
		// 客户端请求非空验证
		if(reqValuationRule == null || !ToolUtil.validateParam(reqValuationRule)){
			return null;
		}
		
		return valuationRuleDao.getChargeRuleList(reqValuationRule.getCityId());
	}

	/**
	 * 
	 * @Title: getChargeRuleByVehicleLevelId 
	 * @Description: 根据车辆Id获取车辆计价规则
	 * @param reqValuationRuleByVehicleId 客户端请求参数
	 * @author YHQ 
	 * @since V2.5.7
	 * @return ResValuationRule    返回类型
	 * 
	 */
	@Override
	public ResValuationRule getChargeRuleByVehicleLevelId(ReqValuationRuleByVehicleId reqValuationRuleByVehicleId) {
		
		// 客户端请求非空验证
		if(reqValuationRuleByVehicleId == null || !ToolUtil.validateParam(reqValuationRuleByVehicleId)){
			return null;
		}
		
		return valuationRuleDao.getChargeRuleByVehicleLevelId(reqValuationRuleByVehicleId.getVehicleLevelId());
	}

}
